﻿using ManagementTools.Forms;
using ManagementTools.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ManagementTools
{
    public partial class MainForm : Form
    {
       
        public MainForm()
        {
            InitializeComponent();
        }

        public void ShowStaInfo(string info)
        {
            staUser.Text = info;
        }
        public void ShowText(string text)
        {
            txtEcho.Text=text;
        }
        public void AppendEcho(string text)
        {
            txtEcho.Text += "\r\n" + text;
        }
        private void MainForm_Load(object sender, EventArgs e)
        {
            StringBuilder sb= new StringBuilder();
            sb.AppendLine("使用说明");
            sb.AppendLine("1. 生成应用枚举类");
            sb.AppendLine("  在后台管理工具中管理字典后，用此工具生成在后台cs代码中能使用的枚举类，以供调用，并保证枚举与前台所用字典同步");
            sb.AppendLine("2. 生成应用数据表");
            sb.AppendLine("  由于系统没有提供生成表工具，这里根据实体类创建数据表");
            sb.AppendLine("3. 切换1对多级联代码模板，进入后台代码生成器生成前后台代码");
            sb.AppendLine("  系统默认提供了外键功能，但前台界面不好用，此功能提供1对多级联代码");
            sb.AppendLine("4. 一对多代码补充");
            sb.AppendLine("  对第三步提供的代码的完善");
            txtEcho.Text = sb.ToString();
            if(App.LoginUser!=null)
            {
                staUser.Text = "Login: " + App.LoginUser.Account;
                mnuApifunc.Enabled = true;
            }
            else
            {
                staInfo.Text = "UnkownUser";
                mnuApifunc.Enabled = false;
            }
        }
        private void docxTestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DocxTest frm = new DocxTest();
            frm.Tag = this;
            frm.ShowDialog();
        }

        private void dicToEnumToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmDicToEnum frm = new FrmDicToEnum(App.SugarClient);
            frm.Tag = this;
            frm.ShowDialog();
        }

        private void mnuPostCodeGen_Click(object sender, EventArgs e)
        {
            FrmPostCodeGenerate frm = new FrmPostCodeGenerate();
            frm.Tag = this;
            frm.ShowDialog();
        }

        private void 初始化数据表ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmInitialApplicationTables frm=new FrmInitialApplicationTables();
            frm.Tag = this;
            frm.ShowDialog(this);
        }

        private void mnuImportDictAndEnum_Click(object sender, EventArgs e)
        {
            FrmImportDictionaryMakeEnum frm = new FrmImportDictionaryMakeEnum();
            frm.Tag = this;
            frm.ShowDialog();
        }

        private void mnuImportUsers_Click(object sender, EventArgs e)
        {
            FrmOrgUserInporter frm=new FrmOrgUserInporter();
            frm.ShowDialog();
        }
    }
}
